package br.fmapn.process.entities;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Transient;

/**
 * Entity class representing a BusinessProcess 
 * @author Fellipe
 */

@NamedQueries({
	@NamedQuery(name="findAllBusinessProcess", 
			query="SELECT bp FROM BusinessProcess bp")
})

@Entity
public class BusinessProcess implements Serializable {
	private static final long serialVersionUID = -2507431381950981933L;
	private int id;
	private String name;
	private List<BusinessOperation> businessOperations = new ArrayList<BusinessOperation>();
	private int numberExecutions;
	
	public BusinessProcess() {
		super();
	}
	
	@Id
	@GeneratedValue
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	@OneToMany(mappedBy="businessProcess", cascade=CascadeType.ALL)
	public List<BusinessOperation> getBusinessOperations() {
		return businessOperations;
	}
	public void setBusinessOperations(List<BusinessOperation> businessOperations) {
		this.businessOperations = businessOperations;
	}

	public void setNumberExecutions(int numberExecutions) {
		this.numberExecutions = numberExecutions;
	}
	
	@Transient
	public int getNumberExecutions() {
		return numberExecutions;
	}
}
